#ifndef DIALOG_SETTINGS_H
#define DIALOG_SETTINGS_H

#include <QDialog>
#include <QtCore>
#include <QtGui>

#include <QItemDelegate>
#include <QModelIndex>
#include <QSize>
#include <QSpinBox>

#include "node.h"
#include "edge.h"

class EdgeDelegate;

namespace Ui
{
    class Dialog_settings;
}

class GraphDelegate : public QItemDelegate
{
    Q_OBJECT
public:
    explicit GraphDelegate(QObject *parent = 0);
};

class GraphItemModel : public QStandardItemModel
{
    Q_OBJECT
public:
    explicit GraphItemModel(QObject *parent = 0);

    Qt::ItemFlags flags ( const QModelIndex & index) const;
    //virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;

    void setBalRow(int bal_row);
private:
    int m_bal_row;
};

// Элемент сети: ветвь или узел
enum NetElementType
{
    ET_NODE = 0,
    ET_EDGE = 1
};


class Dialog_settings : public QDialog
{
    Q_OBJECT

public:
    Dialog_settings(QWidget *parent, NetElementType entype);
    ~Dialog_settings();

    void SetModelArgument(int col, int row);
    void SetColHeaderData(int colnumber, QString caption);

    void SetIndexValue (int row, int col, QVariant value );
    void GetIndexValue (int row, int col, QVariant &value );

    void setBal(int bal);
    int getBal();

signals:

    void EdgeDataChanged(const QList<int>&, const QList<double>&, const QList<double>&,
                         const QList<double>&, const QList<double>&,
                         const QList<double>&, const QList<double>&);
    void NodeDataChanged(const QList<int>&, const QList<double>&,
                         const QList<double>&, const QList<double>&,
                         const QList<double>&, const QList<double>&);

private slots:


    void on_pushButton_ok_clicked();

    void on_pushButton_cancel_clicked();

private:
    Ui::Dialog_settings *ui;
    GraphItemModel      *model;
    GraphDelegate       *delegate;

    NetElementType      m_entype;

    void  setentype(NetElementType entype);
    NetElementType getentype();

    int m_bal_row;

};



class EdgeDelegate : public GraphDelegate
{
    Q_OBJECT
public:
    explicit EdgeDelegate(QObject *parent = 0);

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void    setEditorData(QWidget *editor, const QModelIndex &index) const;
    void    setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;

    void    updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
signals:

public slots:

};


class NodeDelegate : public GraphDelegate
{
    Q_OBJECT
public:
    explicit NodeDelegate(QObject *parent = 0);

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void    setEditorData(QWidget *editor, const QModelIndex &index) const;
    void    setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;

    void    updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;

signals:

public slots:

};


#endif // DIALOG_SETTINGS_H
